//
//  CZFooterView.swift
//  git
//
//  Created by 徐 鹏超 on 16/4/11.
//  Copyright © 2016年 徐 鹏飞. All rights reserved.
//

import UIKit

class CZFooterView: UIView {

    var footerStatusModel: CZStatusModel?{
        
        didSet{
            
            // 赋值
            let count = footerStatusModel?.comments_count ?? 0
            if count == 0 {
                commentButton.setTitle("评论", forState: UIControlState.Normal)
            } else {
                commentButton.setTitle("\(count)", forState: UIControlState.Normal)
            }
            
            
            retweetButton.setTitle("\(footerStatusModel?.reposts_count ?? 0)", forState: UIControlState.Normal)
            
            goodsButton.setTitle("\(footerStatusModel?.attitudes_count ?? 0)", forState: UIControlState.Normal)
            
            
        }
        
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setupUI(){
        
        addSubview(retweetButton)
        addSubview(commentButton)
        addSubview(goodsButton)
        
        
        // 添加约束
        retweetButton.snp_makeConstraints { (make) -> Void in
            
            make.left.equalTo(self.snp_left)
            make.top.equalTo(self.snp_top)
            make.right.equalTo(commentButton.snp_left)
            make.bottom.equalTo(self.snp_bottom)
            
            
            // 等宽约束
            make.width.equalTo(commentButton.snp_width)
        }
        
        commentButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(self.snp_top)
            make.right.equalTo(goodsButton.snp_left)
            make.bottom.equalTo(self.snp_bottom)
        }
        
        goodsButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(self.snp_top)
            make.right.equalTo(self.snp_right)
            make.bottom.equalTo(self.snp_bottom)
            
            make.width.equalTo(commentButton.snp_width)
        }
        
    }
    
    //MARK:--懒加载
    /*
    /// 转发按钮
    private lazy var retweetButton: UIButton = {
    
    let button = UIButton(type: UIButtonType.Custom)
    
    // 设置button 的title 和 image
    button.setImage(UIImage(named: "timeline_icon_retweet"), forState: UIControlState.Normal)
    
    button.setTitle("转发", forState: UIControlState.Normal)
    
    button.setTitleColor(UIColor.lightGrayColor(), forState: UIControlState.Normal)
    
    // 设置button的字体
    button.titleLabel?.font = UIFont.systemFontOfSize(15)
    
    return button
    
    }()
    /// 评论按钮
    private lazy var commentButton: UIButton = {
    
    let button = UIButton(type: UIButtonType.Custom)
    
    // 设置button 的title 和 image
    button.setImage(UIImage(named: "timeline_icon_comment"), forState: UIControlState.Normal)
    
    button.setTitle("评论", forState: UIControlState.Normal)
    
    button.setTitleColor(UIColor.lightGrayColor(), forState: UIControlState.Normal)
    
    // 设置button的字体
    button.titleLabel?.font = UIFont.systemFontOfSize(15)
    
    return button
    
    }()
    /// 点赞的按钮
    private lazy var goodsButton: UIButton = {
    
    let button = UIButton(type: UIButtonType.Custom)
    
    // 设置button 的title 和 image
    button.setImage(UIImage(named: "timeline_icon_like"), forState: UIControlState.Normal)
    
    button.setTitle("点赞", forState: UIControlState.Normal)
    
    button.setTitleColor(UIColor.lightGrayColor(), forState: UIControlState.Normal)
    
    // 设置button的字体
    button.titleLabel?.font = UIFont.systemFontOfSize(15)
    
    return button
    
    }()
    */
    
    private lazy var retweetButton: UIButton = UIButton(image: "timeline_icon_retweet", title: "转发", size: 15)
    
    private lazy var commentButton: UIButton = UIButton(image: "timeline_icon_comment", title: "评论", size: 15)
    
    private lazy var goodsButton: UIButton = UIButton(image: "timeline_icon_like", title: "点赞", size: 15)


}
